package com.lianxi.rabbitmq.shoudongyingda.workqueues;

import com.lianxi.rabbitmq.util.RabbitMqUtils;
import com.rabbitmq.client.Channel;

import java.io.IOException;
import java.util.Scanner;
import java.util.concurrent.TimeoutException;


public class Product1 {

    private final static String QUEUE_NAME = "hello";

    public static void main(String[] args) throws IOException, TimeoutException {
        Producer();
    }


    //测试消费者轮训
    public static void Producer() throws IOException, TimeoutException {
        Channel channel = RabbitMqUtils.getChannel();
        channel.queueDeclare(QUEUE_NAME, false, false, false, null);

        //设置非轮训
        System.out.println("请输入信息：");
        //从控制台发送信息
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String next = scanner.next();
            channel.basicPublish("", QUEUE_NAME, null, next.getBytes());
            System.out.println(">>>>>>消息发送完毕<<<<<<");

        }

    }

}
